<template>
  <div class="article">
    <van-nav-bar
      class="top"
      title="文章详情"
      left-arrow
      fixed
      placeholder
      @click-left="$router.push('/layout/home')"
    />
    <div class="content">
      <h3 class="title">{{ info.title }}</h3>
      <div class="user">
        <img class="avatar" :src="info.aut_photo" alt="" />
        <div class="name">
          <div>{{ info.aut_name }}</div>
          <div class="tiem">{{ info.pubdate }}</div>
        </div>
        <van-button round type="info" size="small"> + 关注</van-button>
      </div>
      <div class="html" v-html="info.content" />
      <van-divider>end</van-divider>
      <div style="text-align:center">
        <van-button
          style="margin-right: 14px"
          plain
          round
          type="primary"
          icon="good-job-o">
          点赞
          </van-button>
        <van-button plain round type="danger" icon="delete-o">
          不喜欢
        </van-button>
      </div>
    </div>
    <Comment />
  </div>
</template>

<script>
import { articles } from '@/api/article'
import Comment from './components/comment.vue'
export default {
  name: 'article',
  components: {
    Comment
  },
  data () {
    return {
      id: this.$route.query.id,
      info: ''
    }
  },
  created () {
    this.getDate()
  },
  methods: {
    async getDate () {
      const res = await articles(this.id)
      this.info = res.data.data
    }
  }
}
</script>

<style lang="less" scoped>
.van-nav-bar {
  ::v-deep.van-icon {
    color: #fff;
  }
}
.content {
  padding: 46px 15px;
  .title {
    font-size: 22px;
    padding: 12px 0;
  }
  .user {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    .avatar {
      width: 50px;
      height: 50px;
      border-radius: 50%;
      object-fit: cover;
      background-color: #000;
    }
    .name {
      flex: 1;
      margin-left: 15px;
      .time {
        color: #999;
      }
    }
  }
  .html {
    width: 100%;
    overflow: auto;
    ::v-deep p {
      word-break: break-all;
      word-wrap: break-word;
      img {
        width: 100%;
      }
    }
    ::v-deep pre {
      margin: 10px 0;
      border-radius: 3px;
      background-color: #000;
      color: #fff;
      overflow: auto;
    }
  }
}
</style>
